package com.realbrand.net.realbrandpay.weight;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.Button;

import com.realbrand.net.realbrandpay.R;

/**
 * Created by Administrator on 2017/9/11.
 */

public class MyTimeCount extends CountDownTimer {
    Button button;
    String code;
    Context context;

    public MyTimeCount(long millisInFuture, long countDownInterval, Button button, String code, Context context) {
        super(millisInFuture, countDownInterval);
        this.button = button;
        this.code = code;
        this.context=context;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        button.setBackground(context.getResources().getDrawable(R.drawable.bt_regist));
        button.setClickable(false);
        button.setText(millisUntilFinished / 1000 + "秒后可重新发送");
    }

    @Override
    public void onFinish() {
        button.setText("重新获取验证码");
        button.setClickable(true);
        button.setBackground(context.getResources().getDrawable(R.drawable.bt_regist));
        code = "";
    }
}
